import sys
import os
import subprocess
import json
maFileList = []
MAYABATCHPATH = r'C:/Program Files/Autodesk/Maya2018/bin/mayabatch.exe'

currentPath = os.path.dirname(__file__).replace("\\","/")
publishPath = '%s/myPlayBlast.py' % currentPath.replace("\\", "/")
melFile = '%s/imp_path.py' % currentPath.replace("\\", "/")
#print ("currentPath", currentPath)
#print ("melFile", melFile)
path =  "E:/test/"
listpath = os.listdir (path)
#print ( listpath )
for ii in listpath :
    maFileList.append(path + ii)
Check = ''
with open ( "F:/QL_tool_file/Window_Tool/LogicalFile/Batch_Submission_V2/CheckInformation.txt" , "r" ) as file :
    content = file.read()
    #data = json.load ( file )
    all_txt = content.split("\n")
    for i in all_txt:
        link = i.split(",,,")
        Check += link[1] + ","

melFile = "\"python(\\\"execfile('" + melFile + "')\\\")\""
for ii in maFileList:
    print(ii)
    ## python方法
    publishPath =  publishPath
    maPath =  ii
    currentFolder = os.path.dirname(ii)
    cmd = MAYABATCHPATH + " -command " + melFile + " " + content + " "+ Check + " " + publishPath + " " + maPath + " " + currentFolder
    #print(cmd)
    subprocess.check_call ( cmd )
    ## Mel方法
    #cmd = '"{mayaBatchPath}" -script "{melFile}" "{newFile}" "{publishPath}" "{maPath}" "{currentFolder}"'.format ( mayaBatchPath = MAYABATCHPATH , melFile = melFile , newFile = newFile , publishPath = publishPath , maPath = ii , currentFolder = os.path.dirname ( ii ) ,)
    #subprocess.check_call ( cmd , shell = True )
